package cn.conchit.apccontroldemo.graph.canvas;


import cn.conchit.apccontroldemo.graph.canvas.Edge;
import cn.conchit.apccontroldemo.graph.canvas.GraphNode;
import cn.conchit.apccontroldemo.graph.exception.DirectGraphException;
import cn.conchit.apccontroldemo.graph.exception.NoSuchGraphNodeException;

import java.util.HashSet;
import java.util.List;

/**
 * 有向图接口
 * 对于定点+边的操作：
 * （1）增加
 * （2）删除
 * （3）获取
 *
 * @author hetao
 * @version 1.0
 */
public interface IDirectGraph<V, E> {

    /**
     * 新增顶点
     * @param v 顶点
     * @version 1.0
     */
    void addVertex(final V v);

    /**
     * 删除顶点
     * @param v 顶点
     * @version 1.0
     * @return 是否删除成功
     */
    boolean removeVertex(final V v) throws DirectGraphException;

    /**
     * 获取顶点
     * @param index 下标
     * @version 1.0
     * @return 返回顶点信息
     */
    V getVertex(final int index) throws NoSuchGraphNodeException;

    /**
     * 新增边
     * @param edge 边
     * @version 1.0
     */
    void addEdge(final Edge<E> edge) throws DirectGraphException;

    /**
     * 移除边
     * @param edge 边信息
     * @version 1.0
     */
    boolean removeEdge(final Edge<E> edge) throws DirectGraphException;


    boolean removeEdge(final int tailIndex, final int headIndex) throws DirectGraphException;

    /**
     * 获取边信息
     * @param tailIndex 弧尾开始节点
     * @param headIndex 弧头结束节点
     * @version 1.0
     */
    Edge<E> getEdge(final int tailIndex, final int headIndex) throws DirectGraphException;

    List<V> bfs(V root);

    List<V> dfs(V root);

//    List<HashSet<CmptNode>> sequence() throws CloneNotSupportedException, DirectGraphException;

}